Skip to content

Reduce token usage when running Review Notes#434

Merged
dkotter merged 2 commits intoWordPress:developfrom
dkotter:fix/review-notes-tokens
Apr 20, 2026
Merged

Reduce token usage when running Review Notes#434
dkotter merged 2 commits intoWordPress:developfrom
dkotter:fix/review-notes-tokens

Conversation

@dkotter
Copy link
Copy Markdown
Collaborator

@dkotter dkotter commented Apr 15, 2026

What?

Try to reduce the token usage when running Review Notes

Why?

It was reported that it can be easy to run into hourly token limits when running Review Notes. While some of this is unavoidable (for instance, if you have a really long post), we do control how much extra context we send with each request and we can reduce that a bit while still maintaining quality results.

How?

  • For each block being reviewed, we send the content of that block and a certain amount of content around that block. Previously that was set to up-to 2000 characters before and after. This PR reduces that to 800
  • We had extra instructions around this context and that has been removed (similarly to how we removed this from alt text generation)

In testing on a fairly short article (12 paragraphs, 5 headings), here's the before and after token usage:

Before After Savings
27,237 prompt tokens 20,224 prompt tokens 29.55% reduction

Use of AI Tools

None for the code in this PR. Did use Claude Code running Opus 4.6 to build a helper plugin to log token usage to the debug log

Testing Instructions

  1. Pull this PR down and run npm i && npm run build
  2. Enable the Review Notes experiment
  3. Create a post
  4. Trigger Review Notes from the sidebar
  5. Ensure it still works as expected

Changelog Entry

Changed - Reduce the context we send when running Review Notes to decrease the amount of tokens used.

Open WordPress Playground Preview

… that context as we already have this called out in our system instructions
@dkotter dkotter added this to the 0.8.0 milestone Apr 15, 2026
@dkotter dkotter self-assigned this Apr 15, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 15, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: dkotter <dkotter@git.wordpress.org>
Co-authored-by: jeffpaul <jeffpaul@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.44%. Comparing base (219f424) to head (7bf85be).
⚠️ Report is 22 commits behind head on develop.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop     #434   +/-   ##
==========================================
  Coverage      68.44%   68.44%           
  Complexity       846      846           
==========================================
  Files             56       56           
  Lines           4095     4095           
==========================================
  Hits            2803     2803           
  Misses          1292     1292           
Flag Coverage Δ
unit 68.44% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dkotter dkotter requested a review from jeffpaul April 15, 2026 20:01
jeffpaul
jeffpaul previously approved these changes Apr 16, 2026
Copy link
Copy Markdown
Member

@jeffpaul jeffpaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested Review Notes with this change and things continue to work as expected

@dkotter dkotter merged commit 16faa35 into WordPress:develop Apr 20, 2026
17 checks passed
@github-project-automation github-project-automation Bot moved this from Needs review to Done in WordPress AI Planning & Roadmap Apr 20, 2026
@dkotter dkotter deleted the fix/review-notes-tokens branch April 20, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants